/*
 * PKL 51 GUNUNG KIDUL
 * Subseksie DATA ENTRY + CAPI
 */
package pkl51.model;

import java.io.Serializable;
import pkl51.entity.Blok6c;
import pkl51.error.EntityException;
import pkl51.model.event.Blok6CListener;
import pkl51.service.Blok6cDao;
import pkl51.service.impl.Blok6cDaoImpl;

/**
 *
 * @author tyas
 */
public class Blok6CModel implements Serializable{

    private static Blok6CModel instance;
    private static final long serialVersionUID = 5925587721231518844L;
    private String B6CR1;
    private String B6CR2;
    private String B6CR3;
    private String B6CR4;
    private String B6CR5;
    private String B6CR6;
    private String B6CR7;
    private String B6CR8;
    private String B6CR9;
    private String B6CR10;
    private String B6CR11;
    private String B6CR12;
    private String B6CR13;
    private String B6CR14;
    private String B6CR15;
    private String B6CR16;
    private String B6CR17;
    private String B6CR18;
    //private String sebutkanB6CR17;
    private String NKS;
    private Blok6CListener listener;

    private Blok6CModel() {
        this.NKS = Blok123Model.getInstance().getNKS();
    }

    public static Blok6CModel getInstance() {
        if (instance == null) {
            instance = new Blok6CModel();
        }
        return instance;
    }

    public void setForDB(String B6CR1, String B6CR2, String B6CR3, String B6CR4, String B6CR5, String B6CR6, String B6CR7, String B6CR8, String B6CR9, String B6CR10, String B6CR11, String B6CR12, String B6CR13, String B6CR14, String B6CR15, String B6CR16, String B6CR17, String B6CR18//, String sebutkanB6CR17
            ) {
        this.B6CR1 = B6CR1;
        this.B6CR2 = B6CR2;
        this.B6CR3 = B6CR3;
        this.B6CR4 = B6CR4;
        this.B6CR5 = B6CR5;
        this.B6CR6 = B6CR6;
        this.B6CR7 = B6CR7;
        this.B6CR8 = B6CR8;
        this.B6CR9 = B6CR9;
        this.B6CR10 = B6CR10;
        this.B6CR11 = B6CR11;
        this.B6CR12 = B6CR12;
        this.B6CR13 = B6CR13;
        this.B6CR14 = B6CR14;
        this.B6CR15 = B6CR15;
        this.B6CR16 = B6CR16;
        this.B6CR17 = B6CR17;
        this.B6CR18 = B6CR18;
      //  this.sebutkanB6CR17 = sebutkanB6CR17;
    }

    public String getB6CR1() {
        return B6CR1;
    }

    public void setB6CR1(String B6CR1) {
        this.B6CR1 = B6CR1;
        fireOnChange(this);
    }

    public String getB6CR2() {
        return B6CR2;
    }

    public void setB6CR2(String B6CR2) {
        this.B6CR2 = B6CR2;
        fireOnChange(this);
    }

    public String getB6CR3() {
        return B6CR3;
    }

    public void setB6CR3(String B6CR3) {
        this.B6CR3 = B6CR3;
        fireOnChange(this);
    }

    public String getB6CR4() {
        return B6CR4;
    }

    public void setB6CR4(String B6CR4) {
        this.B6CR4 = B6CR4;
        fireOnChange(this);
    }

    public String getB6CR5() {
        return B6CR5;
    }

    public void setB6CR5(String B6CR5) {
        this.B6CR5 = B6CR5;
        fireOnChange(this);
    }

    public String getB6CR6() {
        return B6CR6;
    }

    public void setB6CR6(String B6CR6) {
        this.B6CR6 = B6CR6;
        fireOnChange(this);
    }

    public String getB6CR7() {
        return B6CR7;
    }

    public void setB6CR7(String B6CR7) {
        this.B6CR7 = B6CR7;
        fireOnChange(this);
    }

    public String getB6CR8() {
        return B6CR8;
    }

    public void setB6CR8(String B6CR8) {
        this.B6CR8 = B6CR8;
        fireOnChange(this);
    }

    public String getB6CR9() {
        return B6CR9;
    }

    public void setB6CR9(String B6CR9) {
        this.B6CR9 = B6CR9;
        fireOnChange(this);
    }

    public String getB6CR10() {
        return B6CR10;
    }

    public void setB6CR10(String B6CR10) {
        this.B6CR10 = B6CR10;
        fireOnChange(this);
    }

    public String getB6CR11() {
        return B6CR11;
    }

    public void setB6CR11(String B6CR11) {
        this.B6CR11 = B6CR11;
        fireOnChange(this);
    }

    public String getB6CR12() {
        return B6CR12;
    }

    public void setB6CR12(String B6CR12) {
        this.B6CR12 = B6CR12;
        fireOnChange(this);
    }

    public String getB6CR13() {
        return B6CR13;
    }

    public void setB6CR13(String B6CR13) {
        this.B6CR13 = B6CR13;
        fireOnChange(this);
    }

    public String getB6CR14() {
        return B6CR14;
    }

    public void setB6CR14(String B6CR14) {
        this.B6CR14 = B6CR14;
        fireOnChange(this);
    }

    public String getB6CR15() {
        return B6CR15;
    }

    public void setB6CR15(String B6CR15) {
        this.B6CR15 = B6CR15;
        fireOnChange(this);
    }

    public String getB6CR16() {
        return B6CR16;
    }

    public void setB6CR16(String B6CR16) {
        this.B6CR16 = B6CR16;
        fireOnChange(this);
    }

    public String getB6CR17() {
        return B6CR17;
    }

    public void setB6CR17(String B6CR17) {
        this.B6CR17 = B6CR17;
        fireOnChange(this);
    }

    public String getB6CR18() {
        return B6CR18;
    }

    public void setB6CR18(String B6CR18) {
        this.B6CR18 = B6CR18;
        fireOnChange(this);
    }

    public String getNKS() {
        return NKS;
    }

    public void setNKS(String NKS) {
        this.NKS = NKS;
        fireOnChange(this);
    }

    public Blok6CListener getListener() {
        return listener;
    }

    public void setListener(Blok6CListener listener) {
        this.listener = listener;
    }

    /*public String getSebutkanB6CR17() {
        return sebutkanB6CR17;
    }

    public void setSebutkanB6CR17(String sebutkanB6CR17) {
        this.sebutkanB6CR17 = sebutkanB6CR17;
        fireOnChange(this);
    }*/

    protected void fireOnChange(Blok6CModel model) {
        if (listener != null) {
            listener.onChange(this);
        }
    }

    public void insertBlok6c() throws EntityException {
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6cDao dao = new Blok6cDaoImpl();
        Blok6c blok6c = new Blok6c();
        blok6c.setNKS(NKS);
        blok6c.setB6CR1(Integer.valueOf(B6CR1));
        blok6c.setB6CR2(Integer.valueOf(B6CR2));
        blok6c.setB6CR3(Integer.valueOf(B6CR3));
        blok6c.setB6CR4(Integer.valueOf(B6CR4));
        blok6c.setB6CR5(Integer.valueOf(B6CR5));
        blok6c.setB6CR6(Integer.valueOf(B6CR6));
        blok6c.setB6CR7(Integer.valueOf(B6CR7));
        blok6c.setB6CR8(Integer.valueOf(B6CR8));
        blok6c.setB6CR9(Integer.valueOf(B6CR9));
        blok6c.setB6CR10(Integer.valueOf(B6CR10));
        blok6c.setB6CR11(Integer.valueOf(B6CR11));
        blok6c.setB6CR12(Integer.valueOf(B6CR12));
        blok6c.setB6CR13(Integer.valueOf(B6CR13));
        blok6c.setB6CR14(Integer.valueOf(B6CR14));
        blok6c.setB6CR15(Integer.valueOf(B6CR15));
        blok6c.setB6CR16(Integer.valueOf(B6CR16));
        blok6c.setB6CR17(Integer.valueOf(B6CR17));
        blok6c.setB6CR18(Integer.valueOf(B6CR18));

        dao.insertBlok6c(blok6c);
    }

    public void updateBlok6c() throws EntityException {
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6cDao dao = new Blok6cDaoImpl();

        Blok6c blok6c = new Blok6c();
        blok6c.setNKS(NKS);
        blok6c.setB6CR1(Integer.valueOf(B6CR1));
        blok6c.setB6CR2(Integer.valueOf(B6CR2));
        blok6c.setB6CR3(Integer.valueOf(B6CR3));
        blok6c.setB6CR4(Integer.valueOf(B6CR4));
        blok6c.setB6CR5(Integer.valueOf(B6CR5));
        blok6c.setB6CR6(Integer.valueOf(B6CR6));
        blok6c.setB6CR7(Integer.valueOf(B6CR7));
        blok6c.setB6CR8(Integer.valueOf(B6CR8));
        blok6c.setB6CR9(Integer.valueOf(B6CR9));
        blok6c.setB6CR10(Integer.valueOf(B6CR10));
        blok6c.setB6CR11(Integer.valueOf(B6CR11));
        blok6c.setB6CR12(Integer.valueOf(B6CR12));
        blok6c.setB6CR13(Integer.valueOf(B6CR13));
        blok6c.setB6CR14(Integer.valueOf(B6CR14));
        blok6c.setB6CR15(Integer.valueOf(B6CR15));
        blok6c.setB6CR16(Integer.valueOf(B6CR16));
        blok6c.setB6CR17(Integer.valueOf(B6CR17));
        blok6c.setB6CR18(Integer.valueOf(B6CR18));

        dao.updateBlok6c(blok6c);
    }

    public void getBlok6cByNKS() throws EntityException {
        this.NKS = Blok123Model.getInstance().getNKS();
        Blok6cDao dao = new Blok6cDaoImpl();
        Blok6c blok6c = dao.getBlok6cByNKS(NKS);
        setNKS(blok6c.getNKS());
        setB6CR1(String.valueOf(blok6c.getB6CR1()));
        setB6CR2(String.valueOf(blok6c.getB6CR2()));
        setB6CR3(String.valueOf(blok6c.getB6CR3()));
        setB6CR4(String.valueOf(blok6c.getB6CR4()));
        setB6CR5(String.valueOf(blok6c.getB6CR5()));
        setB6CR6(String.valueOf(blok6c.getB6CR6()));
        setB6CR7(String.valueOf(blok6c.getB6CR7()));
        setB6CR8(String.valueOf(blok6c.getB6CR8()));
        setB6CR9(String.valueOf(blok6c.getB6CR9()));
        setB6CR10(String.valueOf(blok6c.getB6CR10()));
        setB6CR11(String.valueOf(blok6c.getB6CR11()));
        setB6CR12(String.valueOf(blok6c.getB6CR12()));
        setB6CR13(String.valueOf(blok6c.getB6CR13()));
        setB6CR14(String.valueOf(blok6c.getB6CR14()));
        setB6CR15(String.valueOf(blok6c.getB6CR15()));
        setB6CR16(String.valueOf(blok6c.getB6CR16()));
        setB6CR17(String.valueOf(blok6c.getB6CR17()));
        setB6CR18(String.valueOf(blok6c.getB6CR18()));
    }
    
    public void resetModel() {
        setNKS("");
        setB6CR1("");
        setB6CR2("");
        setB6CR3("");
        setB6CR4("");
        setB6CR5("");
        setB6CR6("");
        setB6CR7("");
        setB6CR8("");
        setB6CR9("");
        setB6CR10("");
        setB6CR11("");
        setB6CR12("");
        setB6CR13("");
        setB6CR14("");
        setB6CR15("");
        setB6CR16("");
        setB6CR17("");
        setB6CR18("");
    }
}
